package com.numbersix.ant.locetask;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class LOCEHolder {
	
	private String fileSetDescription;
	private List counterList = new ArrayList();
	private long overallCount; 
	
	public LOCEHolder(String fileSetDescription) {
		this.fileSetDescription = fileSetDescription;
	}
	
	/**
	 * @return Returns the counterList.
	 */
	public List getCounterList() {
		return counterList;
	}
	/**
	 * @return Returns the fileSetDescription.
	 */
	public String getFileSetDescription() {
		return fileSetDescription;
	}
	
	public void addCounter(AbstractFileTypeLOCECounter counter) {
		counterList.add(counter);
	}
	
	public long getTotalLines() {
		long totalCount = 0;
		AbstractFileTypeLOCECounter counter;
		Iterator i = counterList.iterator();		
		while (i.hasNext()) {
			counter = (AbstractFileTypeLOCECounter)i.next();
			totalCount += counter.getSetCount();
		}
		
		return totalCount;
		
	}

	/**
	 * @param overallCount The overallCount to set.
	 */
	public void setOverallCount(long overallCount) {
		this.overallCount = overallCount;
	}
	
	public String getPercentageOfOverallCount() {
		double overallPercent = (double)getTotalLines()/overallCount;
		return DecimalFormat.getPercentInstance().format(overallPercent);
	}

}
